#include "myreg.h"

REG_STR G_REG[MAX_REG_NUM];
void REG_INI()
{
	READ_ALL_REAG_FORM_FLASH();
//	for(uint16_t i=0;i<MAX_REG_NUM;i++)
//	G_REG[i].name=i;
	G_REG[reg_ID_7022].value=0;
	G_REG[REMOTE].value=0;
  G_REG[MODE].value=0;
	G_REG[reg_verify_7022].value=0;
	G_REG[reg_PGACtrl].value=0x100;
	G_REG[reg_UgainA].value=63900;G_REG[reg_UgainB].value=63378;G_REG[reg_UgainC].value=64065;
	G_REG[reg_IgainA].value=38639;G_REG[reg_IgainB].value=38628;G_REG[reg_IgainC].value=38624;
	//G_REG[reg_PgainA].value=36389;G_REG[reg_PgainB].value=36341;G_REG[reg_PgainC].value=36381;
	G_REG[reg_PgainA].value=36455;G_REG[reg_PgainB].value=36481;G_REG[reg_PgainC].value=36488;
	memset(&KEY_STR[0],0,sizeof(KEY_STR[0]));
	memset(&KEY_STR[1],0,sizeof(KEY_STR[1]));
	memset(&KEY_STR[2],0,sizeof(KEY_STR[2]));

}

void Load_SD(uint8_t *p,uint16_t BA,uint16_t data_length)
{
	static uint16_t i;
	uint16_t temp_buf[512];
	union {
	uint16_t num;
	struct {
	uint8_t lb;
	uint8_t hb;
	}u16;
	}swap16_8;
	
	
	for(i=BA;i<(BA+data_length);i++)
	{
		swap16_8.num=temp_buf[i]=G_REG[i].value;
		p[(i-BA)*2]=swap16_8.u16.hb;
		p[(i-BA)*2+1]=swap16_8.u16.lb;
	};
	

}